/*
 * @lc app=leetcode.cn id=383 lang=cpp
 *
 * [383] 赎金信
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
    bool canConstruct(string ransomNote, string magazine)
    {
        map<char, int> m1, m2;
        for (int i = 0; i < magazine.length(); i++)
        {
            m1[magazine[i]]++;
        }
        for (int i = 0; i < ransomNote.length(); i++)
        {
            if (m1[ransomNote[i]])
                m1[ransomNote[i]]--;
            else
                return false;
        }
        return true;
    }
};
// @lc code=end
